﻿using FrmMain;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FMain
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
        Dao dao = new Dao();
        private void button2_Click(object sender, EventArgs e)
        {
            string loginName = this.textBox1.Text;
            string loginPwd = this.textBox2.Text;
            if (loginName != null && loginPwd != null 
                && !loginName.Equals(string.Empty)&&!loginPwd.Equals(string.Empty)
                ) {
                string sql = string.Format("select count(1) from [User] where Uname in ('{0}')  and Upwd in('{1}')", loginName,loginPwd);
                if (Convert.ToInt32(dao.DoScalar(sql)) > 0)
                {
                    MessageBox.Show("登录成功");
                    this.Visible = false;
                    Form2 frm = new Form2();
                    string sqlId= string.Format("select UId from [User] where Uname in ('{0}')  and Upwd in('{1}')", loginName, loginPwd);
                    int Id = Convert.ToInt32(dao.DoScalar(sqlId));
                    frm.loginID = Id;
                    frm.Show();
                }
                else {
                    MessageBox.Show("登录失败");
                }
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            frmZhu fz = new frmZhu();
            fz.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
